You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto-save launched project to recent projects and canonicalize paths
Summary
• Automatically records the launched project in recent-projects.json on CLI boot (cli/src/index.tsx) whenever the user starts Freebuff directly inside a project (i.e. when not showing the project picker).
• Previously, saveRecentProject was only invoked inside onSelectProject when navigating through the project picker, meaning standard launches (cd ~/my-project && freebuff) never populated "Recent Projects".
• Canonicalizes projectPath with path.resolve() in saveRecentProject and removeRecentProject (cli/src/utils/recent-projects.ts) to avoid duplicate entries and filtering mismatches caused by relative paths or trailing slashes.
• Switched recent-projects.ts to import getConfigDir from ./config-dir instead of ./auth to avoid pulling in the entire auth/api stack.
• Adds comprehensive unit tests in cli/src/__tests__/utils/recent-projects.test.ts covering path canonicalization, disk validation filtering, LRU-style capping, project removal, and clearing.
Test plan
[✓] bun test --config=/dev/null src/__tests__/utils/recent-projects.test.ts — 8 pass, 0 fail
[✓] bun run --cwd cli typecheck — 0 errors
[✓] PR hygiene check passed
Good bug fix. The core issue you found is real: saveRecentProject was only wired into onSelectProject, so direct launches from inside a project (cd ~/my-project && freebuff) never landed in "Recent Projects" — this is exactly the kind of small papercut worth porting.
The canonicalization change in cli/src/utils/recent-projects.ts (using path.resolve in both saveRecentProject and removeRecentProject, and filtering by resolved path rather than raw string) is the right fix for the trailing-slash / relative-path duplicate-entry bug, and it's covered well by the new tests (recent-projects.test.ts), including the trailing-slash canonicalization case and the LRU cap test.
Switching the getConfigDir import from ./auth to ./config-dir is a nice, unrelated-but-welcome cleanup that avoids pulling the auth/api stack into a simple filesystem utility — worth calling out explicitly in the commit message if you split this in the private tree, since reviewers may want it as a separate atomic change.
One thing I can't verify from the diff alone: the cli/src/index.tsx hunk assumes projectRoot is already in scope at that point in main() and that saveRecentProject is already imported (both plausible given the existing onSelectProject usage, but worth double-checking against the actual file). Also worth considering whether saveRecentProject should be skipped when the resolved path isn't a valid project root at all (e.g. arbitrary directories where shouldShowProjectPicker still returns false) — the existence check in saveRecentProject covers the disk-existence case, but not necessarily "is this actually a project".
Overall: focused, tested, low blast radius. Good work for a first contribution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Auto-save launched project to recent projects and canonicalize paths
Summary
• Automatically records the launched project in
recent-projects.jsonon CLI boot (cli/src/index.tsx) whenever the user starts Freebuff directly inside a project (i.e. when not showing the project picker).• Previously,
saveRecentProjectwas only invoked insideonSelectProjectwhen navigating through the project picker, meaning standard launches (cd ~/my-project && freebuff) never populated "Recent Projects".• Canonicalizes
projectPathwithpath.resolve()insaveRecentProjectandremoveRecentProject(cli/src/utils/recent-projects.ts) to avoid duplicate entries and filtering mismatches caused by relative paths or trailing slashes.• Switched
recent-projects.tsto importgetConfigDirfrom./config-dirinstead of./authto avoid pulling in the entire auth/api stack.• Adds comprehensive unit tests in
cli/src/__tests__/utils/recent-projects.test.tscovering path canonicalization, disk validation filtering, LRU-style capping, project removal, and clearing.Test plan
[✓]
bun test --config=/dev/null src/__tests__/utils/recent-projects.test.ts— 8 pass, 0 fail[✓]
bun run --cwd cli typecheck— 0 errors[✓] PR hygiene check passed